# Simple Makefile to build epd_driver static library and run unit tests on host
# Note: Driver layer that depends on ESP-IDF/Waveshare DEV_Config is not built in host tests.

AR := ar
CC := gcc
CFLAGS := -Wall -Wextra -std=c11 -O2
INCLUDES := -I./ -I./hal -I./driver -I./gfx

# Library sources (HAL/driver may depend on embedded SDK; we compile only gfx for host tests)
LIB_SRCS := gfx/epd_gfx.c epd_class.c
LIB_OBJS := $(LIB_SRCS:.c=.o)

LIB_NAME := libepd_driver.a

.PHONY: all clean lib test

all: lib

lib: $(LIB_OBJS)
	$(AR) rcs $(LIB_NAME) $(LIB_OBJS)

%.o: %.c
	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

clean:
	rm -f $(LIB_OBJS) $(LIB_NAME) tests/*.o tests/test_epd

# Host test builds (gfx only)
TEST_SRCS := tests/test_epd.c gfx/epd_gfx.c
TEST_OBJS := $(TEST_SRCS:.c=.o)

test: $(TEST_OBJS)
	$(CC) $(CFLAGS) $(INCLUDES) -o tests/test_epd $(TEST_OBJS)
	@echo "Running unit tests..."
	@./tests/test_epd